﻿{include file=header.html}
<script language="javascript" type="text/javascript" src="{res file=js/jquery-1.2.6.js}"></script>
<script language="javascript" type="text/javascript" src="{lib file=jquery.plugins/jquery.validate.js}"></script>
<script type="text/javascript">
$(function(){
	$.validator.addMethod("check_brand_name",function(){
	company_id=$("#company_id").val();
	brand_name=$("#brand_name").val();
	brand_id="{$smarty.get.brand_id}";
	var ret=$.ajax({
	async:false,
	url:'index.php?app=brand&act=check_brand&brand_name=' + brand_name + '&company_id='+company_id+ '&brand_id='+brand_id,
	dataType:'json',
	type:'get'
	});
	return ret.responseText=="true";
	},"{$lang.brand_name_is_exist}");
	
    var brand_form_valid=$('#brand_form').validate({
        onkeyup : false,
		onfocusout : false,
		rules : {
			company_id: {
				required: true
			},
			brand_name: {
				required: true,
				check_brand_name: true
			},

		},
		messages : {
			brand_name: {
				required: '{$lang.brand_name_not_empty}'
			},
			company_id: {
				required: '{$lang.company_not_empty}'
				
			}
		}
	});
	
	$('#company_id').change(function(){
		brand_form_valid.showErrors("company_id");
	});
	 
});
</script>
<style>
label.error {margin-left:2em; color:#FF0000;}
.tab-frame{width:900px;}

</style>
<body>
<div class="sub-body">
<div class="tab-frame">
<div class="tab-title-1">
<!--{if $smarty.get.act eq 'add'}--><span>{$lang.add_new_brand}</span><!--{else}--><span>{$lang.edit_brand}</span><!--{/if}-->
</div>
<form action="{url app=brand&act=$smarty.get.act}{if $smarty.get.brand_id}&amp;brand_id={$smarty.get.brand_id}{/if}" method="post" id="brand_form">
<table width="100%" cellspacing="0" cellpadding="0" class="tab-display">
	<tr>
		<th width="100" align="right">{$lang.brand_name}：</th>
		<td align="left"><input type="text" name="brand_name" id="brand_name" value="{$brand.brand_name}" class="input-7" /></td>
	</tr>
    <tr>
		<th width="100" align="right">{$lang.brand_addr}：</th>
		<td align="left"><input type="text" name="brand_addr" id="brand_addr" value="{$brand.brand_addr}" class="input-7" />多个地址以 , 分隔</td>
	</tr>
    <tr>
		<th width="100" align="right">{$lang.company_name}：</th>
		<td align="left"><select name="company_id" id="company_id">
        <option value=""></option>
        {foreach from=$companys item=company}
		  <option {if $company.company_id eq $brand.company_id}selected{/if} value="{$company.company_id}">{$company.company_name}</option>
         {/foreach}
		</select></td>
	</tr>
	<tr>
		<th align="right">{$lang.description}：</th>
		<td align="left"><textarea name="description" rows="6" class="input-7">{$brand.description}</textarea></td>
	</tr>
	<tr>
		<th align="right">{$lang.if_show}：</th>
		<td align="left"><label><input type="radio" name="if_show" value="1" {if $brand.if_show == 1}checked="checked"{/if} />{$lang.yes}</label>&nbsp;&nbsp;&nbsp;&nbsp;<label><input type="radio" name="if_show" value="0" {if $brand.if_show == 0}checked="checked"{/if} />{$lang.no}</label></td>
	</tr>
	<tr>
		<td colspan="2" align="center"><input type="submit" value="{$lang.submit}" class="btn-2"/></td>
	</tr>
</table>
</form>
<script language="javascript" type="text/javascript" src="{res file=js/tab_color.js}"></script>
</div>
</div>
</body>
</html>